if statement(条件语句/if 语句):一种编程中的控制结构,用来在条件为真(true)时执行某段代码;通常也可搭配 else(否则)或 else if(否则如果)处理其他情况。不同编程语言的写法略有差异。
/ɪf ˈsteɪtmənt/
If the password is wrong, the program shows an error message.
如果密码不正确,程序会显示错误信息。
If the weather improves, we’ll go hiking; if not, we’ll stay home and finish the report.
如果天气转好,我们就去徒步;如果不行,我们就待在家把报告写完。
if 源自古英语 gif(“如果、假如”之意),表示条件;statement 来自拉丁语 stāre(“站立、陈述”相关),经由法语进入英语,表示“陈述、语句”。合在一起,if statement 字面意思就是“用来表达条件的语句”,在计算机语境中指“条件分支语句”。